// 4 分治策略
// 4.2 矩阵乘法的 Strassen 算法
// TODO: 矩阵乘法的 Strassen 算法

/// 矩阵乘法。
pub fn square_matrix_multiply(a: &Vec<Vec<f64>>, b: &Vec<Vec<f64>>) -> Vec<Vec<f64>> {
    let n = a.len();
    let mut c = vec![vec![0.0; n]; n];
    for i in 0..n {
        for j in 0..n {
            for k in 0..n {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    c
}

mod tests {
    #[test]
    fn square_matrix_multiply() {
        let a = vec![vec![1.0, 2.0], vec![3.0, 4.0]];
        let b = vec![vec![5.0, 6.0], vec![7.0, 8.0]];
        assert_eq!(
            super::square_matrix_multiply(&a, &b),
            vec![vec![19.0, 22.0], vec![43.0, 50.0]]
        );
    }
}
